/*
 * Created on 27/02/2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.potiorb.orb.marshal;


public class Any {

	private TypeCode typeCode;
	private java.lang.Object value;

	public TCKind kind ()
	{
		return typeCode.kind ();
	}
	public TypeCode type ()
	{
		return typeCode;
	}
	public void type (TypeCode t)
	{
		typeCode = t;
		value = null;
	}
	public java.lang.Object value ()
	{
		return value;
	}
	public int _get_TCKind ()
	{
		return TCKind._tk_any;
	}
	public void insert_short (short s)
	{
		value = new Short (s);
		typeCode = new TypeCodeImpl(TCKind.tk_short);
	}
	public short extract_short ()
	{
		return ((Short)value).shortValue ();
	}
	public void insert_long (int i)
	{
		value = new Integer (i);
		typeCode = new TypeCodeImpl(TCKind.tk_long);
	}

	public int extract_long ()
	{
		return ((Integer)value).intValue ();
	}
	public void insert_float (float f)
	{
		value = new Float (f);
		typeCode = new TypeCodeImpl(TCKind.tk_float);
	}

	public float extract_float ()
	{
		return ((Float)value).floatValue ();
	}
	public void insert_double (double d)
	{
		value = new Double (d);
		typeCode = new TypeCodeImpl(TCKind.tk_double);
	}

	public double extract_double ()
	{
		return ((Double)value).doubleValue ();
	}

	// boolean

	public void insert_boolean (boolean b)
	{
		value = new Boolean (b);
		typeCode = new TypeCodeImpl(TCKind.tk_boolean);
	}

	public boolean extract_boolean ()
	{
		return ((Boolean)value).booleanValue ();
	}

	// char

	public void insert_char (char c)
	{
		value = new Character (c);
		typeCode = new TypeCodeImpl(TCKind.tk_char);
	}

	public char extract_char ()
	{
		return ((Character)value).charValue ();
	}

	// octet

	public void insert_octet (byte b)
	{
		value = new Byte (b);
		typeCode = new TypeCodeImpl(TCKind.tk_octet);
	}

	public byte extract_octet ()
	{
		return ((Byte)value).byteValue ();
	}

	// any

	public void insert_any (Any a)
	{
		value = a;
		typeCode = new TypeCodeImpl(TCKind.tk_any);
	}

	public Any extract_any ()
	{
		return (Any)value;
	}
	// string

	public void insert_string (String s)
	{
		value = s;
		typeCode = new TypeCodeImpl(TCKind.tk_string);
	}

	public String extract_string ()
	{
		return value.toString ();
	}
}
